package version_info

import (
	"fmt"
	"github.com/gin-gonic/gin"
)

type VersionView struct {
	VersionService *VersionService
}

func NewVersionView() *VersionView {
	return &VersionView{
		VersionService: NewVersionService(),
	}

}

func (view *VersionView) getVersionInfoView(ctx *gin.Context) {
	data := ctx.Request
	fmt.Println(data)
	resp := ""

	//获取参数
	if versionName, isExist := ctx.GetQuery("version_name"); isExist == true {
		versionInfo, _, err := view.VersionService.GetVersionInfos(ctx, versionName)
		if err != nil {
			resp = fmt.Sprintf("error:%v", err)
		}
		resp = fmt.Sprintf("versionInfo:%v", versionInfo)
	}

	ctx.JSON(200, gin.H{
		"retcode": 0,
		"msg":     "success",
		"data":    resp,
	})
}
